package helper.xls;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.WritableWorkbook;

/**
 *
 * @author Andrzej Biernacki
 */
public class TemplateProducer{



    /**
     * pobiera szablon z katalogu Web Content/szablony/xls
     * @param os
     * @param file - nazwa pliku bez rozszerzenia
     * @return
     * @throws java.io.IOException
     * @throws jxl.read.biff.BiffException
     */
    public WritableWorkbook getTemplate(OutputStream os, String file) throws IOException, BiffException {
        InputStream is = TemplateProducer.class.getClassLoader().getResourceAsStream( file );
        Workbook workbook = Workbook.getWorkbook(is);
        return Workbook.createWorkbook(os, workbook);
    }

        public WritableWorkbook getTemplate(String outputFile, String file) throws IOException, BiffException {
        InputStream is = TemplateProducer.class.getClassLoader().getResourceAsStream( file );
        Workbook workbook = Workbook.getWorkbook(is);
        return Workbook.createWorkbook(new File(outputFile), workbook);
    }


}
